<template>
  <div>
    <input type="text" v-if="isShow" ref="input" />
    <button v-else @click="focusInput">点击搜索</button>
  </div>
</template>
 
<script>
export default {
  data() {
    return {
      isShow:false
    };
  },

  methods: {
    focusInput(){
      this.isShow= !this.isShow

      this.$nextTick(()=>{
      this.$$refs.input.focus()
        
      })
    }
  }
};
</script>

<style scoped>
     
</style>